package environmentvariable

import (
	"os"
)

func SetEnvironmentVariables() {
	//区分环境,兼容本地和其他环境
	env := os.Getenv("ENV_SERVER")
	if env == "" {
		env = os.Getenv("DEPLOYMENT")
		setEnvVariable("ENV_SERVER", env)
	}
	//设置数据库
	//setEnvVariable("STORENAME", "dance_two_two_tiktok")
	//setEnvVariable("STORENAME", "./logs/pet_battle/")
	//setEnvVariable("KAFKA_TOPIC_NOTICE", fmt.Sprintf("dance_two_two_tiktok-notice-topic-%s", env)) //设置需要的topic
	//setEnvVariable("KAFKA_TOPIC_ROUND_GAME_DETAIL", fmt.Sprintf("dance_two_two_tiktok-round-game-detail-topic-%s", env)) //游戏局kafka主体
	if env == "dev" {
		//setEnvVariable("DOCUMENT_STORE_URL", "mongodb://admin:123456@106.14.8.156:27017/?replicaSet=myrs")
		//setEnvVariable("MYSQL_DANCE_TIKTOK", "root:PXDN93VRKUm8TeE7@tcp(106.14.8.156:33069)/dance_two_two_tiktok_dev?charset=utf8mb4&parseTime=True&loc=Local")
		//setEnvVariable("MEMORY_STORE_URL", "redis://:G62m50oigInC30sf@106.14.8.156:36379")
		//setEnvVariable("TIKTOK_APP_ID", "tt33d94564acef77f510")
		//setEnvVariable("TIKTOK_APP_SECRET", "0c0c026bb1d69fba3bb14d4285920621437dedd4")
		//setEnvVariable("KAFKA_BROKERS", "47.122.26.25:9191,47.122.26.25:9192,47.122.26.25:9193") //配置集群
	} else if env == "test" {
		//setEnvVariable("DOCUMENT_STORE_URL", "mongodb://admin:123456@106.14.8.156:27017/?replicaSet=myrs")
		//setEnvVariable("MYSQL_DANCE_TIKTOK", "root:PXDN93VRKUm8TeE7@tcp(106.14.8.156:33069)/dance_two_two_tiktok_test?charset=utf8mb4&parseTime=True&loc=Local")
		//setEnvVariable("MEMORY_STORE_URL", "redis://:G62m50oigInC30sf@106.14.8.156:36379")
		//setEnvVariable("TIKTOK_APP_ID", "tt33d94564acef77f510")
		//setEnvVariable("TIKTOK_APP_SECRET", "0c0c026bb1d69fba3bb14d4285920621437dedd4")
		//setEnvVariable("KAFKA_BROKERS", "47.122.26.25:9191,47.122.26.25:9192,47.122.26.25:9193") //配置集群
	} else if env == "pro" {
		//setEnvVariable("DOCUMENT_STORE_URL", "mongodb://game:gamedsJH279Ikhu@172.25.144.3:27017/?replicaSet=myrs")
		//setEnvVariable("MYSQL_DANCE_TIKTOK", "dev:jxFsEw2WIF8UQrIk@tcp(rm-bp1fdyox88r4722k3lo.mysql.rds.aliyuncs.com:3306)/dance_two_two_tiktok_pro?charset=utf8mb4&parseTime=True&loc=Local")
		//setEnvVariable("MEMORY_STORE_URL", "redis://:G62m50oigInC30sf@172.25.144.2:36379")
		//setEnvVariable("TIKTOK_APP_ID", "tt33d94564acef77f510")
		//setEnvVariable("TIKTOK_APP_SECRET", "0c0c026bb1d69fba3bb14d4285920621437dedd4")
		//setEnvVariable("KAFKA_BROKERS", "47.122.26.25:9191,47.122.26.25:9192,47.122.26.25:9193") //配置集群
	} else {
		setEnvVariable("DOCUMENT_STORE_URL", "mongodb://game:gamedsJH279@123.207.203.98:27017")
		setEnvVariable("DATABASE_URL", "mongodb://game:gamedsJH279@123.207.203.98:27017")
		setEnvVariable("MYSQL_DANCE_TIKTOK", "root:P@lz0!2025@tcp(123.207.203.98:3306)/dance_local?charset=utf8mb4&parseTime=True&loc=Local")
		setEnvVariable("CACHE_URL", "redis://:123456@123.207.203.98:6379")
		setEnvVariable("PORT", "8094")
	}
}
func setEnvVariable(key string, value string) {
	if os.Getenv(key) == "" {
		_ = os.Setenv(key, value)
	}
}
